#51543: Add is_sitemap()#12142
Conversation
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
@mukeshpanchal27 to make reviewing easier i split the second trac ticket to a own PR, see: #12150 |
Co-authored-by: Weston Ruter <westonruter@gmail.com>
|
✅ New code passes PHPStan rule level 10 with the bleeding edge ruleset. |
westonruter
left a comment
There was a problem hiding this comment.
Please add unit tests for the new function and method.
Adds test coverage for the is_sitemap() conditional query tag and the WP_Query::$is_sitemap property introduced for #51543. Tests cover the WP_Query property default, the sitemap index and subtype routes, the sitemap stylesheet route exclusion, is_robots() precedence, the guarantee that a sitemap request is not treated as the home/front page, the global is_sitemap() conditional tag, and the _doing_it_wrong() notice when called before the query is run. Also adds is_sitemap to WP_UnitTestCase::assertQueryTrue() alongside the existing is_robots and is_favicon conditionals for consistency. See #51543.
Tests: Add unit tests for is_sitemap() - Co-Authored-By @nimesh-xecurify
|
@westonruter thanks to @nimesh-xecurify we have now tests as well for this PR :) |
This patch introduces
is_sitemap()as a conditional query tag and adds the$is_sitemapproperty toWP_Query, following the established pattern ofis_robots()andis_favicon().Trac ticket: https://core.trac.wordpress.org/ticket/51543
Use of AI Tools
AI assistance: Yes
Tool(s): GitHub Copilot
Model(s): Claude Sonnet 4.6
Used for: Initial implementation scaffolding. All code was reviewed, adjusted, and tested by me.
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.